//
//  DetailViewController.m
//  CWRD
//
//  Created by lanou on 15/9/17.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "DetailViewController.h"
#import "DetailView.h"
#import "DetailModel.h"
#import "MoviePlayerViewController.h"

@interface DetailViewController ()

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    DetailView *detailView = [[DetailView alloc]initWithFrame:kBounds];
    
    DetailModel *model = self.detailModelArray[self.index];
    [detailView.videoImageView sd_setImageWithURL:[NSURL URLWithString:model.coverForDetail]];
    [detailView.blurImageView sd_setImageWithURL:[NSURL URLWithString:model.coverBlurred]];
    detailView.titleLabel.text = model.title;
    detailView.typeAndTimeLabel.text = [NSString stringWithFormat:@"%@ / %02d'%02d''", model.category, [model.duration intValue] / 60, [model.duration intValue] % 60];
    detailView.introductionLabel.text = model.description;
    detailView.likeCountLabel.text = [model.collectionCount stringValue];
    detailView.shareCountLabel.text = [model.shareCount stringValue];
     

    [detailView.playButton addTarget:self action:@selector(startPlay:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.view addSubview:detailView];
}
-(void)startPlay:(UIButton *)button {
    MoviePlayerViewController *moviePlayerVC = [[MoviePlayerViewController alloc] init];
    [self presentViewController:moviePlayerVC animated:YES completion:nil];
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
